package StudyCode.summary.regularexpressionsmatch;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class SimpIemplementationOfTheUbiquitousGrepCommand {
	public static void main(String[] argv) throws Exception {
		Pattern pattern = Pattern.compile("test");
		Matcher matcher = pattern.matcher("test");
		String file = "e:/Copy/2.txt";
		BufferedReader br = new BufferedReader(new FileReader(file));
		String line;
		while ((line = br.readLine()) != null) {
			matcher.reset(line);
			if (matcher.find()) {
				System.out.println(file + ": " + line);
			}
		}
		br.close();
		System.out.println("匹配结束");
	}
}
